package com.ryder.petmatediarybackend.common.util;

/**
 * 描述: Redis 键常量
 *
 * @author Ryder
 * @version 1.1
 * @since 1.0
 * 更新日期: 2025/10/27
 */
public class RedisKeys {

    /**
     * 用户角色缓存前缀：satoken:role:{userId}
     */
    public static final String SATOKEN_ROLE_PREFIX = "satoken:role";

    /**
     * 用户权限缓存前缀：satoken:permission:{userId}
     */
    public static final String SATOKEN_PERMISSION_PREFIX = "satoken:permission";

    /**
     * Token 黑名单前缀：satoken:blacklist:{tokenValue}
     */
    public static final String SATOKEN_BLACKLIST_PREFIX = "satoken:blacklist";

    /**
     * Refresh Token 前缀：satoken:refresh:{userId}:{deviceType}
     */
    public static final String SATOKEN_REFRESH_PREFIX = "satoken:refresh";

    /**
     * 标签申请间隔限制前缀：pet:tag:apply:limit:{userId}
     */
    public static final String PET_TAG_APPLY_LIMIT_PREFIX = "pet:tag:apply:limit";

    /**
     * 构建用户角色缓存 Key
     */
    public static String buildRoleKey(Long userId) {
        return SATOKEN_ROLE_PREFIX + ":" + userId;
    }

    /**
     * 构建用户权限缓存 Key
     */
    public static String buildPermissionKey(Long userId) {
        return SATOKEN_PERMISSION_PREFIX + ":" + userId;
    }

    /**
     * 构建 Token 黑名单 Key
     */
    public static String buildBlacklistKey(String token) {
        return SATOKEN_BLACKLIST_PREFIX + ":" + token;
    }

    /**
     * 构建 Refresh Token Key
     */
    public static String buildRefreshTokenKey(Long userId, String deviceType) {
        return SATOKEN_REFRESH_PREFIX + ":" + userId + ":" + deviceType;
    }

    /**
     * 构建标签申请间隔限制 Key
     */
    public static String buildTagApplyLimitKey(Long userId) {
        return PET_TAG_APPLY_LIMIT_PREFIX + ":" + userId;
    }
}
